%Compute C-reponse over layered earth
%Cut and paste from Steve's Occam codes
% latest date 20sep2006
%function[Carg] = c_res(F,NLAYER,RHO,THICK),
%F - HZ, RHO Ohm-m, Thick - meters,
% SOME PROBLEMS WITH THIS CODE 3NOV2006
% cres.f is tested OK - Use that!
function[Carg] = c_res(F,NLAYER,RHO,THICK),
  
      OMEGA = 6.283185308*F;
      OMI = OMEGA*1.256637062E-06*(sqrt(-1));
      C = 1./sqrt(OMI/(RHO(NLAYER)));
      for I = NLAYER-1:-1:1,
       CK = sqrt(OMI/(RHO(I)));
       C = exp(-2.*CK*(THICK(I)))*(CK*C-1.)/(CK*C+1.);
       C = (1.+C)/(1.-C)/CK;
      end
      Carg = C;